using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region AppVisitingSite

	/// <summary>
	/// AppVisitingSite object for NHibernate mapped table 'AppVisitingSite'.
	/// </summary>
	[Serializable]
	public class AppVisitingSite : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected Application _application;
		protected DicItem _site;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public AppVisitingSite() { }

		public AppVisitingSite( Application application, DicItem site )
		{
			this._application = application;
			this._site = site;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public Application Application
		{
			get { return _application; }
			set { _application = value; }
		}

		public DicItem Site
		{
			get { return _site; }
			set { _site = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is AppVisitingSite))
				throw new InvalidCastException("This object is not of type AppVisitingSite");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((AppVisitingSite)obj).Id);
					break;
                default:
                    goto case "Id";
			}
            if (AppVisitingSite.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
